author | paulson |
Fri, 02 Mar 2001 13:18:31 +0100 | |
changeset 11189 | 1ea763a5d186 |
parent 10833 | c0844a30ea4e |
child 11192 | 5fd02b905a9a |
permissions | -rw-r--r-- |
1839 | 1 |
(* Title: HOL/Auth/Message |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1996 University of Cambridge |
|
5 |
||
6 |
Datatypes of agents and messages; |
|
1913 | 7 |
Inductive relations "parts", "analz" and "synth" |
1839 | 8 |
*) |
9 |
||
11189 | 10 |
theory Message = Main |
11 |
files ("Message_lemmas.ML"): |
|
12 |
||
13 |
(*Eliminates a commonly-occurring expression*) |
|
14 |
lemma [simp] : "~ (ALL x. x~=y)" |
|
15 |
by blast |
|
16 |
||
17 |
(*Needed occasionally with spy_analz_tac, e.g. in analz_insert_Key_newK*) |
|
18 |
lemma [simp] : "A Un (B Un A) = B Un A" |
|
19 |
by blast |
|
1839 | 20 |
|
21 |
types |
|
22 |
key = nat |
|
23 |
||
24 |
consts |
|
11189 | 25 |
invKey :: "key=>key" |
1839 | 26 |
|
11189 | 27 |
axioms |
28 |
invKey [simp] : "invKey (invKey K) = K" |
|
1839 | 29 |
|
30 |
(*The inverse of a symmetric key is itself; |
|
31 |
that of a public key is the private key and vice versa*) |
|
32 |
||
33 |
constdefs |
|
11189 | 34 |
isSymKey :: "key=>bool" |
1839 | 35 |
"isSymKey K == (invKey K = K)" |
36 |
||
37 |
datatype (*We allow any number of friendly agents*) |
|
2032 | 38 |
agent = Server | Friend nat | Spy |
1839 | 39 |
|
3668 | 40 |
datatype |
7057
b9ddbb925939
tweaked proofs to handle new freeness reasoning for data c onstructors
paulson
parents:
6807
diff
changeset
|
41 |
msg = Agent agent (*Agent names*) |
b9ddbb925939
tweaked proofs to handle new freeness reasoning for data c onstructors
paulson
parents:
6807
diff
changeset
|
42 |
| Number nat (*Ordinary integers, timestamps, ...*) |
b9ddbb925939
tweaked proofs to handle new freeness reasoning for data c onstructors
paulson
parents:
6807
diff
changeset
|
43 |
| Nonce nat (*Unguessable nonces*) |
b9ddbb925939
tweaked proofs to handle new freeness reasoning for data c onstructors
paulson
parents:
6807
diff
changeset
|
44 |
| Key key (*Crypto keys*) |
5234 | 45 |
| Hash msg (*Hashing*) |
46 |
| MPair msg msg (*Compound messages*) |
|
47 |
| Crypt key msg (*Encryption, public- or shared-key*) |
|
1839 | 48 |
|
5234 | 49 |
|
50 |
(*Concrete syntax: messages appear as {|A,B,NA|}, etc...*) |
|
51 |
syntax |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
52 |
"@MTuple" :: "['a, args] => 'a * 'b" ("(2{|_,/ _|})") |
1839 | 53 |
|
9686 | 54 |
syntax (xsymbols) |
11189 | 55 |
"@MTuple" :: "['a, args] => 'a * 'b" ("(2\<lbrace>_,/ _\<rbrace>)") |
9686 | 56 |
|
1839 | 57 |
translations |
58 |
"{|x, y, z|}" == "{|x, {|y, z|}|}" |
|
59 |
"{|x, y|}" == "MPair x y" |
|
60 |
||
61 |
||
2484 | 62 |
constdefs |
63 |
(*Message Y, paired with a MAC computed with the help of X*) |
|
11189 | 64 |
HPair :: "[msg,msg] => msg" ("(4Hash[_] /_)" [0, 1000]) |
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2484
diff
changeset
|
65 |
"Hash[X] Y == {| Hash{|X,Y|}, Y|}" |
2484 | 66 |
|
67 |
(*Keys useful to decrypt elements of a message set*) |
|
11189 | 68 |
keysFor :: "msg set => key set" |
10833 | 69 |
"keysFor H == invKey ` {K. EX X. Crypt K X : H}" |
1839 | 70 |
|
71 |
(** Inductive definition of all "parts" of a message. **) |
|
72 |
||
11189 | 73 |
consts parts :: "msg set => msg set" |
1839 | 74 |
inductive "parts H" |
11189 | 75 |
intros |
76 |
Inj [intro] : "X: H ==> X : parts H" |
|
77 |
Fst: "{|X,Y|} : parts H ==> X : parts H" |
|
78 |
Snd: "{|X,Y|} : parts H ==> Y : parts H" |
|
79 |
Body: "Crypt K X : parts H ==> X : parts H" |
|
80 |
||
81 |
||
82 |
(*Monotonicity*) |
|
83 |
lemma parts_mono: "G<=H ==> parts(G) <= parts(H)" |
|
84 |
apply auto |
|
85 |
apply (erule parts.induct) |
|
86 |
apply (auto dest: Fst Snd Body) |
|
87 |
done |
|
1839 | 88 |
|
89 |
||
1913 | 90 |
(** Inductive definition of "analz" -- what can be broken down from a set of |
1839 | 91 |
messages, including keys. A form of downward closure. Pairs can |
92 |
be taken apart; messages decrypted with known keys. **) |
|
93 |
||
11189 | 94 |
consts analz :: "msg set => msg set" |
1913 | 95 |
inductive "analz H" |
11189 | 96 |
intros |
97 |
Inj [intro,simp] : "X: H ==> X: analz H" |
|
98 |
Fst: "{|X,Y|} : analz H ==> X : analz H" |
|
99 |
Snd: "{|X,Y|} : analz H ==> Y : analz H" |
|
100 |
Decrypt [dest]: |
|
101 |
"[|Crypt K X : analz H; Key(invKey K): analz H|] ==> X : analz H" |
|
1839 | 102 |
|
103 |
||
11189 | 104 |
(*Monotonicity; Lemma 1 of Lowe's paper*) |
105 |
lemma analz_mono: "G<=H ==> analz(G) <= analz(H)" |
|
106 |
apply auto |
|
107 |
apply (erule analz.induct) |
|
108 |
apply (auto dest: Fst Snd) |
|
109 |
done |
|
110 |
||
1913 | 111 |
(** Inductive definition of "synth" -- what can be built up from a set of |
1839 | 112 |
messages. A form of upward closure. Pairs can be built, messages |
3668 | 113 |
encrypted with known keys. Agent names are public domain. |
114 |
Numbers can be guessed, but Nonces cannot be. **) |
|
1839 | 115 |
|
11189 | 116 |
consts synth :: "msg set => msg set" |
1913 | 117 |
inductive "synth H" |
11189 | 118 |
intros |
119 |
Inj [intro]: "X: H ==> X: synth H" |
|
120 |
Agent [intro]: "Agent agt : synth H" |
|
121 |
Number [intro]: "Number n : synth H" |
|
122 |
Hash [intro]: "X: synth H ==> Hash X : synth H" |
|
123 |
MPair [intro]: "[|X: synth H; Y: synth H|] ==> {|X,Y|} : synth H" |
|
124 |
Crypt [intro]: "[|X: synth H; Key(K) : H|] ==> Crypt K X : synth H" |
|
125 |
||
126 |
(*Monotonicity*) |
|
127 |
lemma synth_mono: "G<=H ==> synth(G) <= synth(H)" |
|
128 |
apply auto |
|
129 |
apply (erule synth.induct) |
|
130 |
apply (auto dest: Fst Snd Body) |
|
131 |
done |
|
132 |
||
133 |
(*NO Agent_synth, as any Agent name can be synthesized. Ditto for Number*) |
|
134 |
inductive_cases Nonce_synth [elim!]: "Nonce n : synth H" |
|
135 |
inductive_cases Key_synth [elim!]: "Key K : synth H" |
|
136 |
inductive_cases Hash_synth [elim!]: "Hash X : synth H" |
|
137 |
inductive_cases MPair_synth [elim!]: "{|X,Y|} : synth H" |
|
138 |
inductive_cases Crypt_synth [elim!]: "Crypt K X : synth H" |
|
139 |
||
140 |
use "Message_lemmas.ML" |
|
141 |
||
142 |
method_setup spy_analz = {* |
|
143 |
Method.no_args (Method.METHOD (fn facts => spy_analz_tac 1)) *} |
|
144 |
"for proving the Fake case when analz is involved" |
|
1839 | 145 |
|
146 |
end |