src/HOL/Auth/Guard/Guard_NS_Public.thy
author wenzelm
Sun Nov 02 18:21:45 2014 +0100 (2014-11-02)
changeset 58889 5b7a9633cfa8
parent 48261 865610355ef3
child 61830 4f5ab843cf5b
permissions -rw-r--r--
modernized header uniformly as section;
wenzelm@41775
     1
(*  Title:      HOL/Auth/Guard/Guard_NS_Public.thy
wenzelm@41775
     2
    Author:     Frederic Blanqui, University of Cambridge Computer Laboratory
wenzelm@41775
     3
    Copyright   2002  University of Cambridge
wenzelm@17394
     4
wenzelm@41775
     5
Incorporating Lowe's fix (inclusion of B's identity in round 2).
wenzelm@41775
     6
*)
wenzelm@17394
     7
wenzelm@58889
     8
section{*Needham-Schroeder-Lowe Public-Key Protocol*}
wenzelm@17394
     9
wenzelm@17394
    10
theory Guard_NS_Public imports Guard_Public begin
wenzelm@17394
    11
wenzelm@17394
    12
subsection{*messages used in the protocol*}
wenzelm@17394
    13
wenzelm@20768
    14
abbreviation (input)
wenzelm@21404
    15
  ns1 :: "agent => agent => nat => event" where
wenzelm@20768
    16
  "ns1 A B NA == Says A B (Crypt (pubK B) {|Nonce NA, Agent A|})"
wenzelm@17394
    17
wenzelm@21404
    18
abbreviation (input)
wenzelm@21404
    19
  ns1' :: "agent => agent => agent => nat => event" where
wenzelm@20768
    20
  "ns1' A' A B NA == Says A' B (Crypt (pubK B) {|Nonce NA, Agent A|})"
wenzelm@17394
    21
wenzelm@21404
    22
abbreviation (input)
wenzelm@21404
    23
  ns2 :: "agent => agent => nat => nat => event" where
wenzelm@20768
    24
  "ns2 B A NA NB == Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|})"
wenzelm@17394
    25
wenzelm@21404
    26
abbreviation (input)
wenzelm@21404
    27
  ns2' :: "agent => agent => agent => nat => nat => event" where
wenzelm@20768
    28
  "ns2' B' B A NA NB == Says B' A (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|})"
wenzelm@17394
    29
wenzelm@21404
    30
abbreviation (input)
wenzelm@21404
    31
  ns3 :: "agent => agent => nat => event" where
wenzelm@20768
    32
  "ns3 A B NB == Says A B (Crypt (pubK B) (Nonce NB))"
wenzelm@17394
    33
wenzelm@17394
    34
wenzelm@17394
    35
subsection{*definition of the protocol*}
wenzelm@17394
    36
berghofe@23746
    37
inductive_set nsp :: "event list set"
berghofe@23746
    38
where
wenzelm@17394
    39
berghofe@23746
    40
  Nil: "[]:nsp"
wenzelm@17394
    41
berghofe@23746
    42
| Fake: "[| evs:nsp; X:synth (analz (spies evs)) |] ==> Says Spy B X # evs : nsp"
wenzelm@17394
    43
berghofe@23746
    44
| NS1: "[| evs1:nsp; Nonce NA ~:used evs1 |] ==> ns1 A B NA # evs1 : nsp"
wenzelm@17394
    45
berghofe@23746
    46
| NS2: "[| evs2:nsp; Nonce NB ~:used evs2; ns1' A' A B NA:set evs2 |] ==>
berghofe@23746
    47
  ns2 B A NA NB # evs2:nsp"
wenzelm@17394
    48
berghofe@23746
    49
| NS3: "!!A B B' NA NB evs3. [| evs3:nsp; ns1 A B NA:set evs3; ns2' B' B A NA NB:set evs3 |] ==>
berghofe@23746
    50
  ns3 A B NB # evs3:nsp"
wenzelm@17394
    51
wenzelm@17394
    52
subsection{*declarations for tactics*}
wenzelm@17394
    53
wenzelm@17394
    54
declare knows_Spy_partsEs [elim]
wenzelm@17394
    55
declare Fake_parts_insert [THEN subsetD, dest]
wenzelm@17394
    56
declare initState.simps [simp del]
wenzelm@17394
    57
wenzelm@17394
    58
subsection{*general properties of nsp*}
wenzelm@17394
    59
wenzelm@17394
    60
lemma nsp_has_no_Gets: "evs:nsp ==> ALL A X. Gets A X ~:set evs"
wenzelm@17394
    61
by (erule nsp.induct, auto)
wenzelm@17394
    62
wenzelm@17394
    63
lemma nsp_is_Gets_correct [iff]: "Gets_correct nsp"
wenzelm@17394
    64
by (auto simp: Gets_correct_def dest: nsp_has_no_Gets)
wenzelm@17394
    65
wenzelm@17394
    66
lemma nsp_is_one_step [iff]: "one_step nsp"
berghofe@23746
    67
by (unfold one_step_def, clarify, ind_cases "ev#evs:nsp" for ev evs, auto)
wenzelm@17394
    68
wenzelm@17394
    69
lemma nsp_has_only_Says' [rule_format]: "evs:nsp ==>
wenzelm@17394
    70
ev:set evs --> (EX A B X. ev=Says A B X)"
wenzelm@17394
    71
by (erule nsp.induct, auto)
wenzelm@17394
    72
wenzelm@17394
    73
lemma nsp_has_only_Says [iff]: "has_only_Says nsp"
wenzelm@17394
    74
by (auto simp: has_only_Says_def dest: nsp_has_only_Says')
wenzelm@17394
    75
wenzelm@17394
    76
lemma nsp_is_regular [iff]: "regular nsp"
wenzelm@17394
    77
apply (simp only: regular_def, clarify)
wenzelm@17394
    78
by (erule nsp.induct, auto simp: initState.simps knows.simps)
wenzelm@17394
    79
wenzelm@17394
    80
subsection{*nonce are used only once*}
wenzelm@17394
    81
wenzelm@17394
    82
lemma NA_is_uniq [rule_format]: "evs:nsp ==>
wenzelm@17394
    83
Crypt (pubK B) {|Nonce NA, Agent A|}:parts (spies evs)
wenzelm@17394
    84
--> Crypt (pubK B') {|Nonce NA, Agent A'|}:parts (spies evs)
wenzelm@17394
    85
--> Nonce NA ~:analz (spies evs) --> A=A' & B=B'"
wenzelm@17394
    86
apply (erule nsp.induct, simp_all)
wenzelm@17394
    87
by (blast intro: analz_insertI)+
wenzelm@17394
    88
wenzelm@17394
    89
lemma no_Nonce_NS1_NS2 [rule_format]: "evs:nsp ==>
wenzelm@17394
    90
Crypt (pubK B') {|Nonce NA', Nonce NA, Agent A'|}:parts (spies evs)
wenzelm@17394
    91
--> Crypt (pubK B) {|Nonce NA, Agent A|}:parts (spies evs)
wenzelm@17394
    92
--> Nonce NA:analz (spies evs)"
wenzelm@17394
    93
apply (erule nsp.induct, simp_all)
wenzelm@17394
    94
by (blast intro: analz_insertI)+
wenzelm@17394
    95
wenzelm@17394
    96
lemma no_Nonce_NS1_NS2' [rule_format]:
wenzelm@17394
    97
"[| Crypt (pubK B') {|Nonce NA', Nonce NA, Agent A'|}:parts (spies evs);
wenzelm@17394
    98
Crypt (pubK B) {|Nonce NA, Agent A|}:parts (spies evs); evs:nsp |]
wenzelm@17394
    99
==> Nonce NA:analz (spies evs)"
wenzelm@17394
   100
by (rule no_Nonce_NS1_NS2, auto)
wenzelm@17394
   101
 
wenzelm@17394
   102
lemma NB_is_uniq [rule_format]: "evs:nsp ==>
wenzelm@17394
   103
Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}:parts (spies evs)
wenzelm@17394
   104
--> Crypt (pubK A') {|Nonce NA', Nonce NB, Agent B'|}:parts (spies evs)
wenzelm@17394
   105
--> Nonce NB ~:analz (spies evs) --> A=A' & B=B' & NA=NA'"
wenzelm@17394
   106
apply (erule nsp.induct, simp_all)
wenzelm@17394
   107
by (blast intro: analz_insertI)+
wenzelm@17394
   108
wenzelm@17394
   109
subsection{*guardedness of NA*}
wenzelm@17394
   110
wenzelm@17394
   111
lemma ns1_imp_Guard [rule_format]: "[| evs:nsp; A ~:bad; B ~:bad |] ==>
wenzelm@17394
   112
ns1 A B NA:set evs --> Guard NA {priK A,priK B} (spies evs)"
wenzelm@17394
   113
apply (erule nsp.induct)
wenzelm@17394
   114
(* Nil *)
wenzelm@17394
   115
apply simp_all
wenzelm@17394
   116
(* Fake *)
wenzelm@17394
   117
apply safe
wenzelm@17394
   118
apply (erule in_synth_Guard, erule Guard_analz, simp)
wenzelm@17394
   119
(* NS1 *)
wenzelm@17394
   120
apply blast
wenzelm@17394
   121
apply blast
wenzelm@17394
   122
apply blast
wenzelm@17394
   123
apply (drule Nonce_neq, simp+, rule No_Nonce, simp)
wenzelm@17394
   124
(* NS2 *)
wenzelm@17394
   125
apply (frule_tac A=A in Nonce_neq, simp+)
wenzelm@17394
   126
apply (case_tac "NAa=NA")
wenzelm@17394
   127
apply (drule Guard_Nonce_analz, simp+)
wenzelm@17394
   128
apply (drule Says_imp_knows_Spy)+
wenzelm@17394
   129
apply (drule_tac B=B and A'=Aa in NA_is_uniq, auto)
wenzelm@17394
   130
(* NS3 *)
wenzelm@17394
   131
apply (case_tac "NB=NA", clarify)
wenzelm@17394
   132
apply (drule Guard_Nonce_analz, simp+)
wenzelm@17394
   133
apply (drule Says_imp_knows_Spy)+
wenzelm@17394
   134
by (drule no_Nonce_NS1_NS2, auto)
wenzelm@17394
   135
wenzelm@17394
   136
subsection{*guardedness of NB*}
wenzelm@17394
   137
wenzelm@17394
   138
lemma ns2_imp_Guard [rule_format]: "[| evs:nsp; A ~:bad; B ~:bad |] ==>
wenzelm@17394
   139
ns2 B A NA NB:set evs --> Guard NB {priK A,priK B} (spies evs)" 
wenzelm@17394
   140
apply (erule nsp.induct)
wenzelm@17394
   141
(* Nil *)
wenzelm@17394
   142
apply simp_all
wenzelm@17394
   143
(* Fake *)
wenzelm@17394
   144
apply safe
wenzelm@17394
   145
apply (erule in_synth_Guard, erule Guard_analz, simp)
wenzelm@17394
   146
(* NS1 *)
wenzelm@17394
   147
apply (frule Nonce_neq, simp+, blast, rule No_Nonce, simp)
wenzelm@17394
   148
(* NS2 *)
wenzelm@17394
   149
apply blast
wenzelm@17394
   150
apply blast
wenzelm@17394
   151
apply blast
wenzelm@17394
   152
apply (frule_tac A=B and n=NB in Nonce_neq, simp+)
wenzelm@17394
   153
apply (case_tac "NAa=NB")
wenzelm@17394
   154
apply (drule Guard_Nonce_analz, simp+)
wenzelm@17394
   155
apply (drule Says_imp_knows_Spy)+
wenzelm@17394
   156
apply (drule no_Nonce_NS1_NS2, auto)
wenzelm@17394
   157
(* NS3 *)
wenzelm@17394
   158
apply (case_tac "NBa=NB", clarify)
wenzelm@17394
   159
apply (drule Guard_Nonce_analz, simp+)
wenzelm@17394
   160
apply (drule Says_imp_knows_Spy)+
wenzelm@48261
   161
apply (drule_tac A=Aa and A'=A in NB_is_uniq)
wenzelm@48261
   162
apply auto[1]
wenzelm@48261
   163
apply (auto simp add: guard.No_Nonce)
wenzelm@48261
   164
done
wenzelm@17394
   165
wenzelm@17394
   166
subsection{*Agents' Authentication*}
wenzelm@17394
   167
wenzelm@17394
   168
lemma B_trusts_NS1: "[| evs:nsp; A ~:bad; B ~:bad |] ==>
wenzelm@17394
   169
Crypt (pubK B) {|Nonce NA, Agent A|}:parts (spies evs)
wenzelm@17394
   170
--> Nonce NA ~:analz (spies evs) --> ns1 A B NA:set evs"
wenzelm@17394
   171
apply (erule nsp.induct, simp_all)
wenzelm@17394
   172
by (blast intro: analz_insertI)+
wenzelm@17394
   173
wenzelm@17394
   174
lemma A_trusts_NS2: "[| evs:nsp; A ~:bad; B ~:bad |] ==> ns1 A B NA:set evs
wenzelm@17394
   175
--> Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}:parts (spies evs)
wenzelm@17394
   176
--> ns2 B A NA NB:set evs"
wenzelm@17394
   177
apply (erule nsp.induct, simp_all, safe)
wenzelm@17394
   178
apply (frule_tac B=B in ns1_imp_Guard, simp+)
wenzelm@17394
   179
apply (drule Guard_Nonce_analz, simp+, blast)
wenzelm@17394
   180
apply (frule_tac B=B in ns1_imp_Guard, simp+)
wenzelm@17394
   181
apply (drule Guard_Nonce_analz, simp+, blast)
wenzelm@17394
   182
apply (frule_tac B=B in ns1_imp_Guard, simp+)
wenzelm@17394
   183
by (drule Guard_Nonce_analz, simp+, blast+)
wenzelm@17394
   184
wenzelm@17394
   185
lemma B_trusts_NS3: "[| evs:nsp; A ~:bad; B ~:bad |] ==> ns2 B A NA NB:set evs
wenzelm@17394
   186
--> Crypt (pubK B) (Nonce NB):parts (spies evs) --> ns3 A B NB:set evs"
wenzelm@17394
   187
apply (erule nsp.induct, simp_all, safe)
wenzelm@17394
   188
apply (frule_tac B=B in ns2_imp_Guard, simp+)
wenzelm@17394
   189
apply (drule Guard_Nonce_analz, simp+, blast)
wenzelm@17394
   190
apply (frule_tac B=B in ns2_imp_Guard, simp+)
wenzelm@17394
   191
apply (drule Guard_Nonce_analz, simp+, blast)
wenzelm@17394
   192
apply (frule_tac B=B in ns2_imp_Guard, simp+)
wenzelm@17394
   193
apply (drule Guard_Nonce_analz, simp+, blast, blast)
wenzelm@17394
   194
apply (frule_tac B=B in ns2_imp_Guard, simp+)
wenzelm@17394
   195
by (drule Guard_Nonce_analz, auto dest: Says_imp_knows_Spy NB_is_uniq)
wenzelm@17394
   196
wenzelm@17394
   197
end