src/HOL/Auth/NS_Shared.thy
author wenzelm
Tue, 05 Mar 2002 20:54:55 +0100
changeset 13025 433c57d09d53
parent 11655 923e4d0d36d5
child 13507 febb8e5d2a9d
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/NS_Shared
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     2
    ID:         $Id$
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     5
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     6
Inductive relation "ns_shared" for Needham-Schroeder Shared-Key protocol.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     7
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     8
From page 247 of
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     9
  Burrows, Abadi and Needham.  A Logic of Authentication.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    10
  Proc. Royal Soc. 426 (1989)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    11
*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    12
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    13
theory NS_Shared = Shared:
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    14
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    15
consts  ns_shared   :: "event list set"
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3465
diff changeset
    16
inductive "ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    17
 intros
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    18
	(*Initial trace is empty*)
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    19
  Nil:  "[] \\<in> ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    20
	(*The spy MAY say anything he CAN say.  We do not expect him to
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    21
	  invent new nonces here, but he can also use NS1.  Common to
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    22
	  all similar protocols.*)
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    23
  Fake: "\\<lbrakk>evsf \\<in> ns_shared;  X \\<in> synth (analz (spies evsf))\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    24
	 \\<Longrightarrow> Says Spy B X # evsf \\<in> ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    25
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    26
	(*Alice initiates a protocol run, requesting to talk to any B*)
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    27
  NS1:  "\\<lbrakk>evs1 \\<in> ns_shared;  Nonce NA \\<notin> used evs1\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    28
	 \\<Longrightarrow> Says A Server \\<lbrace>Agent A, Agent B, Nonce NA\\<rbrace> # evs1  \\<in>  ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    29
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    30
	(*Server's response to Alice's message.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    31
	  !! It may respond more than once to A's request !!
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    32
	  Server doesn't know who the true sender is, hence the A' in
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    33
	      the sender field.*)
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    34
  NS2:  "\\<lbrakk>evs2 \\<in> ns_shared;  Key KAB \\<notin> used evs2;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    35
	  Says A' Server \\<lbrace>Agent A, Agent B, Nonce NA\\<rbrace> \\<in> set evs2\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    36
	 \\<Longrightarrow> Says Server A
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    37
	       (Crypt (shrK A)
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    38
		  \\<lbrace>Nonce NA, Agent B, Key KAB,
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    39
		    (Crypt (shrK B) \\<lbrace>Key KAB, Agent A\\<rbrace>)\\<rbrace>)
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    40
	       # evs2 \\<in> ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    41
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    42
	 (*We can't assume S=Server.  Agent A "remembers" her nonce.
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    43
	   Need A \\<noteq> Server because we allow messages to self.*)
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    44
  NS3:  "\\<lbrakk>evs3 \\<in> ns_shared;  A \\<noteq> Server;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    45
	  Says S A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs3;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    46
	  Says A Server \\<lbrace>Agent A, Agent B, Nonce NA\\<rbrace> \\<in> set evs3\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    47
	 \\<Longrightarrow> Says A B X # evs3 \\<in> ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    48
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    49
	(*Bob's nonce exchange.  He does not know who the message came
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    50
	  from, but responds to A because she is mentioned inside.*)
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    51
  NS4:  "\\<lbrakk>evs4 \\<in> ns_shared;  Nonce NB \\<notin> used evs4;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    52
	  Says A' B (Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>) \\<in> set evs4\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    53
	 \\<Longrightarrow> Says B A (Crypt K (Nonce NB)) # evs4 \\<in> ns_shared"
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    54
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    55
	(*Alice responds with Nonce NB if she has seen the key before.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    56
	  Maybe should somehow check Nonce NA again.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    57
	  We do NOT send NB-1 or similar as the Spy cannot spoof such things.
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    58
	  Letting the Spy add or subtract 1 lets him send all nonces.
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    59
	  Instead we distinguish the messages by sending the nonce twice.*)
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    60
  NS5:  "\\<lbrakk>evs5 \\<in> ns_shared;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    61
	  Says B' A (Crypt K (Nonce NB)) \\<in> set evs5;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    62
	  Says S  A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>)
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    63
	    \\<in> set evs5\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    64
	 \\<Longrightarrow> Says A B (Crypt K \\<lbrace>Nonce NB, Nonce NB\\<rbrace>) # evs5 \\<in> ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    65
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    66
	(*This message models possible leaks of session keys.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    67
	  The two Nonces identify the protocol run: the rule insists upon
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    68
	  the true senders in order to make them accurate.*)
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    69
  Oops: "\\<lbrakk>evso \\<in> ns_shared;  Says B A (Crypt K (Nonce NB)) \\<in> set evso;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    70
	  Says Server A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>)
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    71
	      \\<in> set evso\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    72
	 \\<Longrightarrow> Notes Spy \\<lbrace>Nonce NA, Nonce NB, Key K\\<rbrace> # evso \\<in> ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    73
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
    74
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
    75
declare Says_imp_knows_Spy [THEN parts.Inj, dest]
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
    76
declare parts.Body  [dest]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11188
diff changeset
    77
declare Fake_parts_insert_in_Un  [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11188
diff changeset
    78
declare analz_into_parts [dest]
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    79
declare image_eq_UN [simp]  (*accelerates proofs involving nested images*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    80
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    81
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    82
(*A "possibility property": there are traces that reach the end*)
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    83
lemma "A \\<noteq> Server \\<Longrightarrow> \\<exists>N K. \\<exists>evs \\<in> ns_shared.
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    84
                              Says A B (Crypt K \\<lbrace>Nonce N, Nonce N\\<rbrace>) \\<in> set evs"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    85
apply (intro exI bexI)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    86
apply (rule_tac [2] ns_shared.Nil
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    87
       [THEN ns_shared.NS1, THEN ns_shared.NS2, THEN ns_shared.NS3,
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    88
	THEN ns_shared.NS4, THEN ns_shared.NS5])
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    89
apply possibility
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    90
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    91
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    92
(*This version is similar, while instantiating ?K and ?N to epsilon-terms
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    93
lemma "A \\<noteq> Server \\<Longrightarrow> \\<exists>evs \\<in> ns_shared.
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
    94
                Says A B (Crypt ?K \\<lbrace>Nonce ?N, Nonce ?N\\<rbrace>) \\<in> set evs"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    95
*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    96
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    97
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    98
(**** Inductive proofs about ns_shared ****)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    99
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   100
(** Forwarding lemmas, to aid simplification **)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   101
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   102
(*For reasoning about the encrypted portion of message NS3*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   103
lemma NS3_msg_in_parts_spies:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   104
     "Says S A (Crypt KA \\<lbrace>N, B, K, X\\<rbrace>) \\<in> set evs \\<Longrightarrow> X \\<in> parts (spies evs)"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   105
by blast
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   106
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   107
(*For reasoning about the Oops message*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   108
lemma Oops_parts_spies:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   109
     "Says Server A (Crypt (shrK A) \\<lbrace>NA, B, K, X\\<rbrace>) \\<in> set evs
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   110
            \\<Longrightarrow> K \\<in> parts (spies evs)"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   111
by blast
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   112
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   113
(** Theorems of the form X \\<notin> parts (spies evs) imply that NOBODY
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   114
    sends messages containing X! **)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   115
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   116
(*Spy never sees another agent's shared key! (unless it's bad at start)*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   117
lemma Spy_see_shrK [simp]:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   118
     "evs \\<in> ns_shared \\<Longrightarrow> (Key (shrK A) \\<in> parts (spies evs)) = (A \\<in> bad)"
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   119
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   120
apply simp_all
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   121
apply blast+;
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   122
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   123
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   124
lemma Spy_analz_shrK [simp]:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   125
     "evs \\<in> ns_shared \\<Longrightarrow> (Key (shrK A) \\<in> analz (spies evs)) = (A \\<in> bad)"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   126
by auto
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   127
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   128
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   129
(*Nobody can have used non-existent keys!*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   130
lemma new_keys_not_used [rule_format, simp]:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   131
    "evs \\<in> ns_shared \\<Longrightarrow> Key K \\<notin> used evs \\<longrightarrow> K \\<notin> keysFor (parts (spies evs))"
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   132
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   133
apply simp_all
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   134
(*Fake, NS2, NS4, NS5*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   135
apply (blast dest!: keysFor_parts_insert)+
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   136
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   137
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   138
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   139
(** Lemmas concerning the form of items passed in messages **)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   140
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   141
(*Describes the form of K, X and K' when the Server sends this message.*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   142
lemma Says_Server_message_form:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   143
     "\\<lbrakk>Says Server A (Crypt K' \\<lbrace>N, Agent B, Key K, X\\<rbrace>) \\<in> set evs;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   144
       evs \\<in> ns_shared\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   145
      \\<Longrightarrow> K \\<notin> range shrK \\<and>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   146
          X = (Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>) \\<and>
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   147
          K' = shrK A"
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   148
by (erule rev_mp, erule ns_shared.induct, auto)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   149
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   150
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   151
(*If the encrypted message appears then it originated with the Server*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   152
lemma A_trusts_NS2:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   153
     "\\<lbrakk>Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace> \\<in> parts (spies evs);
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   154
       A \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   155
      \\<Longrightarrow> Says Server A (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   156
apply (erule rev_mp)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   157
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   158
apply auto
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   159
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   160
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   161
lemma cert_A_form:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   162
     "\\<lbrakk>Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace> \\<in> parts (spies evs);
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   163
       A \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   164
      \\<Longrightarrow> K \\<notin> range shrK \\<and>  X = (Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>)"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   165
by (blast dest!: A_trusts_NS2 Says_Server_message_form)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   166
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   167
(*EITHER describes the form of X when the following message is sent,
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   168
  OR     reduces it to the Fake case.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   169
  Use Says_Server_message_form if applicable.*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   170
lemma Says_S_message_form:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   171
     "\\<lbrakk>Says S A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   172
       evs \\<in> ns_shared\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   173
      \\<Longrightarrow> (K \\<notin> range shrK \\<and> X = (Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>))
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   174
          \\<or> X \\<in> analz (spies evs)"
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   175
by (blast dest: Says_imp_knows_Spy cert_A_form analz.Inj)
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   176
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   177
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   178
(*Alternative version also provable
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   179
lemma Says_S_message_form2:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   180
  "\\<lbrakk>Says S A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   181
    evs \\<in> ns_shared\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   182
   \\<Longrightarrow> Says Server A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   183
       \\<or> X \\<in> analz (spies evs)"
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   184
apply (case_tac "A \\<in> bad")
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   185
apply (force dest!: Says_imp_knows_Spy [THEN analz.Inj]);
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   186
by (blast dest!: A_trusts_NS2 Says_Server_message_form)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   187
*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   188
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   189
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   190
(****
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   191
 SESSION KEY COMPROMISE THEOREM.  To prove theorems of the form
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   192
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   193
  Key K \\<in> analz (insert (Key KAB) (spies evs)) \\<Longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   194
  Key K \\<in> analz (spies evs)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   195
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   196
 A more general formula must be proved inductively.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   197
****)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   198
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   199
(*NOT useful in this form, but it says that session keys are not used
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   200
  to encrypt messages containing other keys, in the actual protocol.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   201
  We require that agents should behave like this subsequently also.*)
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   202
lemma  "\\<lbrakk>evs \\<in> ns_shared;  Kab \\<notin> range shrK\\<rbrakk> \\<Longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   203
         (Crypt KAB X) \\<in> parts (spies evs) \\<and>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   204
         Key K \\<in> parts {X} \\<longrightarrow> Key K \\<in> parts (spies evs)"
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   205
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   206
apply simp_all
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   207
(*Fake*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   208
apply (blast dest: parts_insert_subset_Un)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   209
(*Base, NS4 and NS5*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   210
apply auto
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   211
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   212
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   213
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   214
(** Session keys are not used to encrypt other session keys **)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   215
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   216
(*The equality makes the induction hypothesis easier to apply*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   217
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   218
lemma analz_image_freshK [rule_format]:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   219
 "evs \\<in> ns_shared \\<Longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   220
   \\<forall>K KK. KK \\<subseteq> - (range shrK) \\<longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   221
             (Key K \\<in> analz (Key`KK \\<union> (spies evs))) =
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   222
             (K \\<in> KK \\<or> Key K \\<in> analz (spies evs))"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   223
apply (erule ns_shared.induct, force)
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   224
apply (drule_tac [7] Says_Server_message_form)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   225
apply (erule_tac [4] Says_S_message_form [THEN disjE])
11117
55358999077d tidying
paulson
parents: 11104
diff changeset
   226
apply analz_freshK
55358999077d tidying
paulson
parents: 11104
diff changeset
   227
apply spy_analz
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   228
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   229
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   230
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   231
lemma analz_insert_freshK:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   232
     "\\<lbrakk>evs \\<in> ns_shared;  KAB \\<notin> range shrK\\<rbrakk> \\<Longrightarrow>
11655
923e4d0d36d5 tuned parentheses in relational expressions;
wenzelm
parents: 11465
diff changeset
   233
       (Key K \\<in> analz (insert (Key KAB) (spies evs))) =
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   234
       (K = KAB \\<or> Key K \\<in> analz (spies evs))"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   235
by (simp only: analz_image_freshK analz_image_freshK_simps)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   236
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   237
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   238
(** The session key K uniquely identifies the message **)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   239
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   240
(*In messages of this form, the session key uniquely identifies the rest*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   241
lemma unique_session_keys:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   242
     "\\<lbrakk>Says Server A (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   243
       Says Server A' (Crypt (shrK A') \\<lbrace>NA', Agent B', Key K, X'\\<rbrace>) \\<in> set evs;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   244
       evs \\<in> ns_shared\\<rbrakk> \\<Longrightarrow> A=A' \\<and> NA=NA' \\<and> B=B' \\<and> X = X'"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   245
apply (erule rev_mp, erule rev_mp, erule ns_shared.induct)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   246
apply simp_all
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   247
apply blast+
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   248
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   249
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   250
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   251
(** Crucial secrecy property: Spy does not see the keys sent in msg NS2 **)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   252
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   253
(*Beware of [rule_format] and the universal quantifier!*)
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   254
lemma secrecy_lemma:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   255
     "\\<lbrakk>Says Server A (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K,
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   256
                                      Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>\\<rbrace>)
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   257
              \\<in> set evs;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   258
         A \\<notin> bad;  B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   259
      \\<Longrightarrow> (\\<forall>NB. Notes Spy \\<lbrace>NA, NB, Key K\\<rbrace> \\<notin> set evs) \\<longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   260
         Key K \\<notin> analz (spies evs)"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   261
apply (erule rev_mp)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   262
apply (erule ns_shared.induct, force)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   263
apply (frule_tac [7] Says_Server_message_form)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   264
apply (frule_tac [4] Says_S_message_form)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   265
apply (erule_tac [5] disjE)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   266
apply (simp_all add: analz_insert_eq analz_insert_freshK pushes split_ifs)
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   267
apply spy_analz  (*Fake*)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   268
apply blast      (*NS2*)
11188
5d539f1682c3 streamlined a proof
paulson
parents: 11150
diff changeset
   269
(*NS3, Server sub-case*) (**LEVEL 8 **)
5d539f1682c3 streamlined a proof
paulson
parents: 11150
diff changeset
   270
apply (blast dest!: Crypt_Spy_analz_bad A_trusts_NS2
5d539f1682c3 streamlined a proof
paulson
parents: 11150
diff changeset
   271
	     dest:  Says_imp_knows_Spy analz.Inj unique_session_keys)
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   272
(*NS3, Spy sub-case; also Oops*)
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   273
apply (blast dest: unique_session_keys)+
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   274
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   275
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   276
11188
5d539f1682c3 streamlined a proof
paulson
parents: 11150
diff changeset
   277
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   278
(*Final version: Server's message in the most abstract form*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   279
lemma Spy_not_see_encrypted_key:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   280
     "\\<lbrakk>Says Server A (Crypt K' \\<lbrace>NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   281
       \\<forall>NB. Notes Spy \\<lbrace>NA, NB, Key K\\<rbrace> \\<notin> set evs;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   282
       A \\<notin> bad;  B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   283
      \\<Longrightarrow> Key K \\<notin> analz (spies evs)"
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   284
by (blast dest: Says_Server_message_form secrecy_lemma)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   285
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   286
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   287
(**** Guarantees available at various stages of protocol ***)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   288
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   289
(*If the encrypted message appears then it originated with the Server*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   290
lemma B_trusts_NS3:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   291
     "\\<lbrakk>Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace> \\<in> parts (spies evs);
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   292
       B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   293
      \\<Longrightarrow> \\<exists>NA. Says Server A
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   294
               (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K,
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   295
                                 Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>\\<rbrace>)
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   296
              \\<in> set evs"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   297
apply (erule rev_mp)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   298
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   299
apply auto
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   300
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   301
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   302
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   303
lemma A_trusts_NS4_lemma [rule_format]:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   304
   "evs \\<in> ns_shared \\<Longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   305
      Key K \\<notin> analz (spies evs) \\<longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   306
      Says Server A (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs \\<longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   307
      Crypt K (Nonce NB) \\<in> parts (spies evs) \\<longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   308
      Says B A (Crypt K (Nonce NB)) \\<in> set evs"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   309
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11188
diff changeset
   310
apply (analz_mono_contra, simp_all)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   311
apply blast     (*Fake*)
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   312
(*NS2: contradiction from the assumptions
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   313
  Key K \\<notin> used evs2  and Crypt K (Nonce NB) \\<in> parts (spies evs2) *)
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   314
apply (force dest!: Crypt_imp_keysFor)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   315
apply blast     (*NS3*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   316
(*NS4*)
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   317
apply (blast dest!: B_trusts_NS3
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   318
	     dest: Says_imp_knows_Spy [THEN analz.Inj]
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   319
                   Crypt_Spy_analz_bad unique_session_keys)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   320
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   321
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   322
(*This version no longer assumes that K is secure*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   323
lemma A_trusts_NS4:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   324
     "\\<lbrakk>Crypt K (Nonce NB) \\<in> parts (spies evs);
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   325
       Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace> \\<in> parts (spies evs);
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   326
       \\<forall>NB. Notes Spy \\<lbrace>NA, NB, Key K\\<rbrace> \\<notin> set evs;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   327
       A \\<notin> bad;  B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   328
      \\<Longrightarrow> Says B A (Crypt K (Nonce NB)) \\<in> set evs"
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   329
by (blast intro: A_trusts_NS4_lemma
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   330
          dest: A_trusts_NS2 Spy_not_see_encrypted_key)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   331
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   332
(*If the session key has been used in NS4 then somebody has forwarded
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   333
  component X in some instance of NS4.  Perhaps an interesting property,
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   334
  but not needed (after all) for the proofs below.*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   335
theorem NS4_implies_NS3 [rule_format]:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   336
  "evs \\<in> ns_shared \\<Longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   337
     Key K \\<notin> analz (spies evs) \\<longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   338
     Says Server A (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs \\<longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   339
     Crypt K (Nonce NB) \\<in> parts (spies evs) \\<longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   340
     (\\<exists>A'. Says A' B X \\<in> set evs)"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   341
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   342
apply analz_mono_contra
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   343
apply (simp_all add: ex_disj_distrib)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   344
apply blast  (*Fake*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   345
apply (blast dest!: new_keys_not_used Crypt_imp_keysFor)  (*NS2*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   346
apply blast  (*NS3*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   347
(*NS4*)
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   348
apply (blast dest!: B_trusts_NS3
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   349
	     dest: Says_imp_knows_Spy [THEN analz.Inj]
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   350
                   unique_session_keys Crypt_Spy_analz_bad)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   351
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   352
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   353
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   354
lemma B_trusts_NS5_lemma [rule_format]:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   355
  "\\<lbrakk>B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk> \\<Longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   356
     Key K \\<notin> analz (spies evs) \\<longrightarrow>
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   357
     Says Server A
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   358
	  (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K,
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   359
			    Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>\\<rbrace>) \\<in> set evs \\<longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   360
     Crypt K \\<lbrace>Nonce NB, Nonce NB\\<rbrace> \\<in> parts (spies evs) \\<longrightarrow>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   361
     Says A B (Crypt K \\<lbrace>Nonce NB, Nonce NB\\<rbrace>) \\<in> set evs"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   362
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   363
apply analz_mono_contra
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   364
apply simp_all
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   365
apply blast  (*Fake*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   366
apply (blast dest!: new_keys_not_used Crypt_imp_keysFor)  (*NS2*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   367
apply (blast dest!: cert_A_form) (*NS3*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   368
(*NS5*)
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   369
apply (blast dest!: A_trusts_NS2
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   370
	     dest: Says_imp_knows_Spy [THEN analz.Inj]
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   371
                   unique_session_keys Crypt_Spy_analz_bad)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   372
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   373
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   374
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   375
(*Very strong Oops condition reveals protocol's weakness*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   376
lemma B_trusts_NS5:
11465
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   377
     "\\<lbrakk>Crypt K \\<lbrace>Nonce NB, Nonce NB\\<rbrace> \\<in> parts (spies evs);
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   378
       Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace> \\<in> parts (spies evs);
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   379
       \\<forall>NA NB. Notes Spy \\<lbrace>NA, NB, Key K\\<rbrace> \\<notin> set evs;
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   380
       A \\<notin> bad;  B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
45d156ede468 Changed 1 to 1' (= Suc 0)
paulson
parents: 11280
diff changeset
   381
      \\<Longrightarrow> Says A B (Crypt K \\<lbrace>Nonce NB, Nonce NB\\<rbrace>) \\<in> set evs"
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   382
by (blast intro: B_trusts_NS5_lemma
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   383
          dest: B_trusts_NS3 Spy_not_see_encrypted_key)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   384
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   385
end