summary |
shortlog |
changelog |
graph |
tags |
branches |
files |
changeset |
file |
revisions |
annotate |
diff |
raw

src/HOL/Auth/TLS.thy

author | paulson |

Fri Sep 19 18:27:31 1997 +0200 (1997-09-19) | |

changeset 3686 | 4b484805b4c4 |

parent 3685 | 5b8c0c8f576e |

child 3687 | fb7d096d7884 |

permissions | -rw-r--r-- |

First working version with Oops event for session keys

1 (* Title: HOL/Auth/TLS

2 ID: $Id$

3 Author: Lawrence C Paulson, Cambridge University Computer Laboratory

4 Copyright 1997 University of Cambridge

6 Inductive relation "tls" for the baby TLS (Transport Layer Security) protocol.

7 This protocol is essentially the same as SSL 3.0.

9 Abstracted from "The TLS Protocol, Version 1.0" by Tim Dierks and Christopher

10 Allen, Transport Layer Security Working Group, 21 May 1997,

11 INTERNET-DRAFT draft-ietf-tls-protocol-03.txt. Section numbers below refer

12 to that memo.

14 An RSA cryptosystem is assumed, and X.509v3 certificates are abstracted down

15 to the trivial form {A, publicKey(A)}privateKey(Server), where Server is a

16 global signing authority.

18 A is the client and B is the server, not to be confused with the constant

19 Server, who is in charge of all public keys.

21 The model assumes that no fraudulent certificates are present, but it does

22 assume that some private keys are to the spy.

24 REMARK. The event "Notes A {|Agent B, Nonce PMS|}" appears in ClientCertKeyEx,

25 CertVerify, ClientFinished to record that A knows M. It is a note from A to

26 herself. Nobody else can see it. In ClientCertKeyEx, the Spy can substitute

27 his own certificate for A's, but he cannot replace A's note by one for himself.

29 The Note event avoids a weakness in the public-key model. Each

30 agent's state is recorded as the trace of messages. When the true client (A)

31 invents PMS, he encrypts PMS with B's public key before sending it. The model

32 does not distinguish the original occurrence of such a message from a replay.

33 In the shared-key model, the ability to encrypt implies the ability to

34 decrypt, so the problem does not arise.

36 Proofs would be simpler if ClientCertKeyEx included A's name within

37 Crypt KB (Nonce PMS). As things stand, there is much overlap between proofs

38 about that message (which B receives) and the stronger event

39 Notes A {|Agent B, Nonce PMS|}.

40 *)

42 TLS = Public +

44 consts

45 (*Pseudo-random function of Section 5*)

46 PRF :: "nat*nat*nat => nat"

48 (*Client, server write keys generated uniformly by function sessionK

49 to avoid duplicating their properties.

50 Theyimplicitly include the MAC secrets.*)

51 sessionK :: "(nat*nat*nat)*bool => key"

53 certificate :: "[agent,key] => msg"

55 defs

56 certificate_def

57 "certificate A KA == Crypt (priK Server) {|Agent A, Key KA|}"

59 syntax

60 clientK, serverK :: "nat*nat*nat => key"

62 translations

63 "clientK (x)" == "sessionK(x,True)"

64 "serverK (x)" == "sessionK(x,False)"

66 rules

67 inj_PRF "inj PRF"

69 (*sessionK is collision-free and makes symmetric keys*)

70 inj_sessionK "inj sessionK"

72 isSym_sessionK "isSymKey (sessionK x)"

74 (*serverK is similar*)

75 inj_serverK "inj serverK"

76 isSym_serverK "isSymKey (serverK x)"

78 (*Clashes with pubK and priK are impossible, but this axiom is needed.*)

79 clientK_range "range clientK <= Compl (range serverK)"

82 consts tls :: event list set

83 inductive tls

84 intrs

85 Nil (*Initial trace is empty*)

86 "[]: tls"

88 Fake (*The spy, an active attacker, MAY say anything he CAN say.*)

89 "[| evs: tls; B ~= Spy;

90 X: synth (analz (spies evs)) |]

91 ==> Says Spy B X # evs : tls"

93 SpyKeys (*The spy may apply PRF, clientK & serverK to available nonces*)

94 "[| evsSK: tls;

95 Says Spy B {|Nonce NA, Nonce NB, Nonce M|} : set evsSK |]

96 ==> Says Spy B {| Nonce (PRF(M,NA,NB)),

97 Key (clientK(NA,NB,M)),

98 Key (serverK(NA,NB,M)) |} # evsSK : tls"

100 ClientHello

101 (*(7.4.1.2)

102 XA represents CLIENT_VERSION, CIPHER_SUITES and COMPRESSION_METHODS.

103 It is uninterpreted but will be confirmed in the FINISHED messages.

104 NA is CLIENT RANDOM, while SID is SESSION_ID.

105 UNIX TIME is omitted because the protocol doesn't use it.

106 May assume NA ~: range PRF because CLIENT RANDOM is 28 bytes

107 while MASTER SECRET is 48 byptes*)

108 "[| evsCH: tls; A ~= B; Nonce NA ~: used evsCH; NA ~: range PRF |]

109 ==> Says A B {|Agent A, Nonce NA, Number SID, Number XA|}

110 # evsCH : tls"

112 ServerHello

113 (*7.4.1.3 of the TLS Internet-Draft

114 XB represents CLIENT_VERSION, CIPHER_SUITE and COMPRESSION_METHOD.

115 SERVER CERTIFICATE (7.4.2) is always present.

116 CERTIFICATE_REQUEST (7.4.4) is implied.*)

117 "[| evsSH: tls; A ~= B; Nonce NB ~: used evsSH; NB ~: range PRF;

118 Says A' B {|Agent A, Nonce NA, Number SID, Number XA|}

119 : set evsSH |]

120 ==> Says B A {|Nonce NB, Number SID, Number XB,

121 certificate B (pubK B)|}

122 # evsSH : tls"

124 ClientCertKeyEx

125 (*CLIENT CERTIFICATE (7.4.6) and KEY EXCHANGE (7.4.7).

126 The client, A, chooses PMS, the PREMASTER SECRET.

127 She encrypts PMS using the supplied KB, which ought to be pubK B.

128 We assume PMS ~: range PRF because a clash betweem the PMS

129 and another MASTER SECRET is highly unlikely (even though

130 both items have the same length, 48 bytes).

131 The Note event records in the trace that she knows PMS

132 (see REMARK at top). *)

133 "[| evsCX: tls; A ~= B; Nonce PMS ~: used evsCX; PMS ~: range PRF;

134 Says B' A {|Nonce NB, Number SID, Number XB, certificate B KB|}

135 : set evsCX |]

136 ==> Says A B {|certificate A (pubK A), Crypt KB (Nonce PMS)|}

137 # Notes A {|Agent B, Nonce PMS|}

138 # evsCX : tls"

140 CertVerify

141 (*The optional Certificate Verify (7.4.8) message contains the

142 specific components listed in the security analysis, F.1.1.2.

143 It adds the pre-master-secret, which is also essential!

144 Checking the signature, which is the only use of A's certificate,

145 assures B of A's presence*)

146 "[| evsCV: tls; A ~= B;

147 Says B' A {|Nonce NB, Number SID, Number XB, certificate B KB|}

148 : set evsCV;

149 Notes A {|Agent B, Nonce PMS|} : set evsCV |]

150 ==> Says A B (Crypt (priK A)

151 (Hash{|Nonce NB, certificate B KB, Nonce PMS|}))

152 # evsCV : tls"

154 (*Finally come the FINISHED messages (7.4.8), confirming XA and XB

155 among other things. The master-secret is PRF(PMS,NA,NB).

156 Either party may sent its message first.*)

158 ClientFinished

159 (*The occurrence of Notes A {|Agent B, Nonce PMS|} stops the

160 rule's applying when the Spy has satisfied the "Says A B" by

161 repaying messages sent by the true client; in that case, the

162 Spy does not know PMS and could not sent ClientFinished. One

163 could simply put A~=Spy into the rule, but one should not

164 expect the spy to be well-behaved.*)

165 "[| evsCF: tls;

166 Says A B {|Agent A, Nonce NA, Number SID, Number XA|}

167 : set evsCF;

168 Says B' A {|Nonce NB, Number SID, Number XB, certificate B KB|}

169 : set evsCF;

170 Notes A {|Agent B, Nonce PMS|} : set evsCF;

171 M = PRF(PMS,NA,NB) |]

172 ==> Says A B (Crypt (clientK(NA,NB,M))

173 (Hash{|Nonce M, Number SID,

174 Nonce NA, Number XA, Agent A,

175 Nonce NB, Number XB, Agent B|}))

176 # evsCF : tls"

178 ServerFinished

179 (*Keeping A' and A'' distinct means B cannot even check that the

180 two messages originate from the same source. *)

181 "[| evsSF: tls;

182 Says A' B {|Agent A, Nonce NA, Number SID, Number XA|}

183 : set evsSF;

184 Says B A {|Nonce NB, Number SID, Number XB,

185 certificate B (pubK B)|}

186 : set evsSF;

187 Says A'' B {|certificate A KA, Crypt (pubK B) (Nonce PMS)|}

188 : set evsSF;

189 M = PRF(PMS,NA,NB) |]

190 ==> Says B A (Crypt (serverK(NA,NB,M))

191 (Hash{|Nonce M, Number SID,

192 Nonce NA, Number XA, Agent A,

193 Nonce NB, Number XB, Agent B|}))

194 # evsSF : tls"

196 ClientAccepts

197 (*Having transmitted ClientFinished and received an identical

198 message encrypted with serverK, the client stores the parameters

199 needed to resume this session.*)

200 "[| evsCA: tls;

201 Notes A {|Agent B, Nonce PMS|} : set evsCA;

202 M = PRF(PMS,NA,NB);

203 X = Hash{|Nonce M, Number SID,

204 Nonce NA, Number XA, Agent A,

205 Nonce NB, Number XB, Agent B|};

206 Says A B (Crypt (clientK(NA,NB,M)) X) : set evsCA;

207 Says B' A (Crypt (serverK(NA,NB,M)) X) : set evsCA |]

208 ==>

209 Notes A {|Number SID, Agent A, Agent B, Nonce M|} # evsCA : tls"

211 ServerAccepts

212 (*Having transmitted ServerFinished and received an identical

213 message encrypted with clientK, the server stores the parameters

214 needed to resume this session.*)

215 "[| evsSA: tls;

216 Says A'' B {|certificate A KA, Crypt (pubK B) (Nonce PMS)|}

217 : set evsSA;

218 M = PRF(PMS,NA,NB);

219 X = Hash{|Nonce M, Number SID,

220 Nonce NA, Number XA, Agent A,

221 Nonce NB, Number XB, Agent B|};

222 Says B A (Crypt (serverK(NA,NB,M)) X) : set evsSA;

223 Says A' B (Crypt (clientK(NA,NB,M)) X) : set evsSA |]

224 ==>

225 Notes B {|Number SID, Agent A, Agent B, Nonce M|} # evsSA : tls"

227 ServerResume

228 (*Resumption is described in 7.3. If B finds the SESSION_ID

229 then he sends HELLO and FINISHED messages, using the

230 previously stored MASTER SECRET*)

231 "[| evsSR: tls; A ~= B; Nonce NB ~: used evsSR; NB ~: range PRF;

232 Notes B {|Number SID, Agent A, Agent B, Nonce M|} : set evsSR;

233 Says A' B {|Agent A, Nonce NA, Number SID, Number XA|}

234 : set evsSR |]

235 ==> Says B A (Crypt (serverK(NA,NB,M))

236 (Hash{|Nonce M, Number SID,

237 Nonce NA, Number XA, Agent A,

238 Nonce NB, Number XB, Agent B|}))

239 # Says B A {|Nonce NB, Number SID, Number XB|} # evsSR : tls"

241 ClientResume

242 (*If the response to ClientHello is ServerResume then send

243 a FINISHED message using the new nonces and stored MASTER SECRET.*)

244 "[| evsCR: tls;

245 Says A B {|Agent A, Nonce NA, Number SID, Number XA|}

246 : set evsCR;

247 Says B' A {|Nonce NB, Number SID, Number XB|} : set evsCR;

248 Notes A {|Number SID, Agent A, Agent B, Nonce M|} : set evsCR |]

249 ==> Says A B (Crypt (clientK(NA,NB,M))

250 (Hash{|Nonce M, Number SID,

251 Nonce NA, Number XA, Agent A,

252 Nonce NB, Number XB, Agent B|}))

253 # evsCR : tls"

255 Oops

256 (*The most plausible compromise is of an old session key. Losing

257 the MASTER SECRET or PREMASTER SECRET is more serious but

258 rather unlikely.*)

259 "[| evso: tls; A ~= Spy;

260 Says A B (Crypt (sessionK((NA,NB,M),b)) X) : set evso |]

261 ==> Says A Spy (Key (sessionK((NA,NB,M),b))) # evso : tls"

263 end