author | xuelei |
Tue, 19 Jun 2018 09:05:57 -0700 | |
branch | JDK-8145252-TLS13-branch |
changeset 56782 | b472b5917a1b |
parent 56708 | 25178bb3e8f5 |
permissions | -rw-r--r-- |
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
1 |
/* |
56557 | 2 |
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. |
3 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
|
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
5 |
* |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
48373
f9152f462cbc
8193758: Update copyright headers of files in src tree that are missing Classpath exception
alanb
parents:
48225
diff
changeset
|
8 |
* published by the Free Software Foundation. Oracle designates this |
f9152f462cbc
8193758: Update copyright headers of files in src tree that are missing Classpath exception
alanb
parents:
48225
diff
changeset
|
9 |
* particular file as subject to the "Classpath" exception as provided |
f9152f462cbc
8193758: Update copyright headers of files in src tree that are missing Classpath exception
alanb
parents:
48225
diff
changeset
|
10 |
* by Oracle in the LICENSE file that accompanied this code. |
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
11 |
* |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
12 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
13 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
14 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
15 |
* version 2 for more details (a copy is included in the LICENSE file that |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
16 |
* accompanied this code). |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
17 |
* |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License version |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
19 |
* 2 along with this work; if not, write to the Free Software Foundation, |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
20 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
21 |
* |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
22 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
23 |
* or visit www.oracle.com if you need additional information or have any |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
24 |
* questions. |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
25 |
*/ |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
26 |
|
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
27 |
package sun.security.ssl; |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
28 |
|
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
29 |
import java.io.IOException; |
56542 | 30 |
import java.nio.ByteBuffer; |
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
31 |
import javax.net.ssl.SSLProtocolException; |
56542 | 32 |
import static sun.security.ssl.SSLExtension.CH_EXTENDED_MASTER_SECRET; |
33 |
import sun.security.ssl.SSLExtension.ExtensionConsumer; |
|
34 |
import static sun.security.ssl.SSLExtension.SH_EXTENDED_MASTER_SECRET; |
|
35 |
import sun.security.ssl.SSLExtension.SSLExtensionSpec; |
|
36 |
import sun.security.ssl.SSLHandshake.HandshakeMessage; |
|
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
37 |
|
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
38 |
/** |
56782 | 39 |
* Pack of the "extended_master_secret" extensions [RFC 7627]. |
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
40 |
*/ |
56542 | 41 |
final class ExtendedMasterSecretExtension { |
42 |
static final HandshakeProducer chNetworkProducer = |
|
43 |
new CHExtendedMasterSecretProducer(); |
|
56704
c3ee22c3a0f6
Minor nits and cleanup across SSLExtension classes
jnimeh
parents:
56559
diff
changeset
|
44 |
static final ExtensionConsumer chOnLoadConsumer = |
56542 | 45 |
new CHExtendedMasterSecretConsumer(); |
46 |
static final HandshakeAbsence chOnLoadAbsence = |
|
47 |
new CHExtendedMasterSecretAbsence(); |
|
48 |
||
49 |
static final HandshakeProducer shNetworkProducer = |
|
50 |
new SHExtendedMasterSecretProducer(); |
|
56704
c3ee22c3a0f6
Minor nits and cleanup across SSLExtension classes
jnimeh
parents:
56559
diff
changeset
|
51 |
static final ExtensionConsumer shOnLoadConsumer = |
56542 | 52 |
new SHExtendedMasterSecretConsumer(); |
53 |
static final HandshakeAbsence shOnLoadAbsence = |
|
54 |
new SHExtendedMasterSecretAbsence(); |
|
55 |
||
56708 | 56 |
static final SSLStringizer emsStringizer = |
57 |
new ExtendedMasterSecretStringizer(); |
|
56542 | 58 |
|
59 |
/** |
|
60 |
* The "extended_master_secret" extension. |
|
61 |
*/ |
|
62 |
static final class ExtendedMasterSecretSpec implements SSLExtensionSpec { |
|
63 |
// A nominal object that does not holding any real renegotiation info. |
|
64 |
static final ExtendedMasterSecretSpec NOMINAL = |
|
65 |
new ExtendedMasterSecretSpec(); |
|
66 |
||
67 |
private ExtendedMasterSecretSpec() { |
|
68 |
// blank |
|
69 |
} |
|
70 |
||
71 |
private ExtendedMasterSecretSpec(ByteBuffer m) throws IOException { |
|
72 |
// Parse the extension. |
|
73 |
if (m.hasRemaining()) { |
|
74 |
throw new SSLProtocolException( |
|
75 |
"Invalid extended_master_secret extension data: " + |
|
76 |
"not empty"); |
|
77 |
} |
|
78 |
} |
|
79 |
||
80 |
@Override |
|
81 |
public String toString() { |
|
82 |
return "<empty>"; |
|
83 |
} |
|
84 |
} |
|
85 |
||
86 |
private static final |
|
56708 | 87 |
class ExtendedMasterSecretStringizer implements SSLStringizer { |
56542 | 88 |
@Override |
89 |
public String toString(ByteBuffer buffer) { |
|
90 |
try { |
|
91 |
return (new ExtendedMasterSecretSpec(buffer)).toString(); |
|
92 |
} catch (IOException ioe) { |
|
93 |
// For debug logging only, so please swallow exceptions. |
|
94 |
return ioe.getMessage(); |
|
95 |
} |
|
96 |
} |
|
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
97 |
} |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
98 |
|
56542 | 99 |
/** |
100 |
* Network data producer of a "extended_master_secret" extension in |
|
101 |
* the ClientHello handshake message. |
|
102 |
*/ |
|
103 |
private static final |
|
104 |
class CHExtendedMasterSecretProducer implements HandshakeProducer { |
|
105 |
// Prevent instantiation of this class. |
|
106 |
private CHExtendedMasterSecretProducer() { |
|
107 |
// blank |
|
108 |
} |
|
109 |
||
110 |
@Override |
|
111 |
public byte[] produce(ConnectionContext context, |
|
112 |
HandshakeMessage message) throws IOException { |
|
113 |
// The producing happens in client side only. |
|
114 |
ClientHandshakeContext chc = (ClientHandshakeContext)context; |
|
115 |
||
116 |
// Is it a supported and enabled extension? |
|
56559
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
117 |
if (!chc.sslConfig.isAvailable(CH_EXTENDED_MASTER_SECRET) || |
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
118 |
!SSLConfiguration.useExtendedMasterSecret || |
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
119 |
!chc.conContext.protocolVersion.useTLS10PlusSpec()) { |
56542 | 120 |
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { |
121 |
SSLLogger.fine( |
|
122 |
"Ignore unavailable extended_master_secret extension"); |
|
123 |
} |
|
124 |
||
125 |
return null; |
|
126 |
} |
|
127 |
||
128 |
if (chc.handshakeSession == null || |
|
129 |
chc.handshakeSession.useExtendedMasterSecret) { |
|
130 |
byte[] extData = new byte[0]; |
|
131 |
chc.handshakeExtensions.put(CH_EXTENDED_MASTER_SECRET, |
|
132 |
ExtendedMasterSecretSpec.NOMINAL); |
|
133 |
||
134 |
return extData; |
|
135 |
} |
|
136 |
||
137 |
return null; |
|
138 |
} |
|
139 |
} |
|
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
140 |
|
56542 | 141 |
/** |
142 |
* Network data producer of a "extended_master_secret" extension in |
|
143 |
* the ServerHello handshake message. |
|
144 |
*/ |
|
145 |
private static final |
|
146 |
class CHExtendedMasterSecretConsumer implements ExtensionConsumer { |
|
147 |
// Prevent instantiation of this class. |
|
148 |
private CHExtendedMasterSecretConsumer() { |
|
149 |
// blank |
|
150 |
} |
|
151 |
||
152 |
@Override |
|
153 |
public void consume(ConnectionContext context, |
|
154 |
HandshakeMessage message, ByteBuffer buffer) throws IOException { |
|
155 |
||
56704
c3ee22c3a0f6
Minor nits and cleanup across SSLExtension classes
jnimeh
parents:
56559
diff
changeset
|
156 |
// The consuming happens in server side only. |
56542 | 157 |
ServerHandshakeContext shc = (ServerHandshakeContext)context; |
158 |
||
159 |
// Is it a supported and enabled extension? |
|
56559
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
160 |
if (!shc.sslConfig.isAvailable(CH_EXTENDED_MASTER_SECRET) || |
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
161 |
!SSLConfiguration.useExtendedMasterSecret || |
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
162 |
!shc.negotiatedProtocol.useTLS10PlusSpec()) { |
56542 | 163 |
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { |
164 |
SSLLogger.fine("Ignore unavailable extension: " + |
|
165 |
CH_EXTENDED_MASTER_SECRET.name); |
|
166 |
} |
|
167 |
return; // ignore the extension |
|
168 |
} |
|
169 |
||
170 |
// Parse the extension. |
|
171 |
ExtendedMasterSecretSpec spec; |
|
172 |
try { |
|
173 |
spec = new ExtendedMasterSecretSpec(buffer); |
|
174 |
} catch (IOException ioe) { |
|
175 |
shc.conContext.fatal(Alert.UNEXPECTED_MESSAGE, ioe); |
|
176 |
return; // fatal() always throws, make the compiler happy. |
|
177 |
} |
|
178 |
||
179 |
if (shc.isResumption && shc.resumingSession != null && |
|
180 |
!shc.resumingSession.useExtendedMasterSecret) { |
|
181 |
// For abbreviated handshake request, If the original |
|
182 |
// session did not use the "extended_master_secret" |
|
183 |
// extension but the new ClientHello contains the |
|
184 |
// extension, then the server MUST NOT perform the |
|
185 |
// abbreviated handshake. Instead, it SHOULD continue |
|
186 |
// with a full handshake. |
|
187 |
shc.isResumption = false; |
|
188 |
shc.resumingSession = null; |
|
189 |
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { |
|
190 |
SSLLogger.fine( |
|
191 |
"abort session resumption which did not use " + |
|
192 |
"Extended Master Secret extension"); |
|
193 |
} |
|
194 |
} |
|
195 |
||
196 |
// Update the context. |
|
197 |
// |
|
198 |
shc.handshakeExtensions.put( |
|
199 |
CH_EXTENDED_MASTER_SECRET, ExtendedMasterSecretSpec.NOMINAL); |
|
200 |
||
201 |
// No impact on session resumption. |
|
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
202 |
} |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
203 |
} |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
204 |
|
56542 | 205 |
/** |
206 |
* The absence processing if a "extended_master_secret" extension is |
|
207 |
* not present in the ClientHello handshake message. |
|
208 |
*/ |
|
209 |
private static final |
|
210 |
class CHExtendedMasterSecretAbsence implements HandshakeAbsence { |
|
211 |
@Override |
|
212 |
public void absent(ConnectionContext context, |
|
213 |
HandshakeMessage message) throws IOException { |
|
214 |
// The producing happens in server side only. |
|
215 |
ServerHandshakeContext shc = (ServerHandshakeContext)context; |
|
216 |
||
217 |
// Is it a supported and enabled extension? |
|
56559
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
218 |
if (!shc.sslConfig.isAvailable(CH_EXTENDED_MASTER_SECRET) || |
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
219 |
!SSLConfiguration.useExtendedMasterSecret) { |
56542 | 220 |
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { |
221 |
SSLLogger.fine("Ignore unavailable extension: " + |
|
222 |
CH_EXTENDED_MASTER_SECRET.name); |
|
223 |
} |
|
224 |
return; // ignore the extension |
|
225 |
} |
|
226 |
||
56559
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
227 |
if (shc.negotiatedProtocol.useTLS10PlusSpec() && |
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
228 |
!SSLConfiguration.allowLegacyMasterSecret) { |
56542 | 229 |
// For full handshake, if the server receives a ClientHello |
230 |
// without the extension, it SHOULD abort the handshake if |
|
231 |
// it does not wish to interoperate with legacy clients. |
|
232 |
// |
|
233 |
// As if extended master extension is required for full |
|
234 |
// handshake, it MUST be used in abbreviated handshake too. |
|
235 |
shc.conContext.fatal(Alert.HANDSHAKE_FAILURE, |
|
236 |
"Extended Master Secret extension is required"); |
|
237 |
} |
|
238 |
||
239 |
if (shc.isResumption && shc.resumingSession != null) { |
|
240 |
if (shc.resumingSession.useExtendedMasterSecret) { |
|
241 |
// For abbreviated handshake request, if the original |
|
242 |
// session used the "extended_master_secret" extension |
|
243 |
// but the new ClientHello does not contain it, the |
|
244 |
// server MUST abort the abbreviated handshake. |
|
245 |
shc.conContext.fatal(Alert.HANDSHAKE_FAILURE, |
|
246 |
"Missing Extended Master Secret extension " + |
|
247 |
"on session resumption"); |
|
248 |
} else { |
|
249 |
// For abbreviated handshake request, if neither the |
|
250 |
// original session nor the new ClientHello uses the |
|
251 |
// extension, the server SHOULD abort the handshake. |
|
56559
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
252 |
if (!SSLConfiguration.allowLegacyResumption) { |
56542 | 253 |
shc.conContext.fatal(Alert.HANDSHAKE_FAILURE, |
254 |
"Missing Extended Master Secret extension " + |
|
255 |
"on session resumption"); |
|
256 |
} else { // Otherwise, continue with a full handshake. |
|
257 |
shc.isResumption = false; |
|
258 |
shc.resumingSession = null; |
|
259 |
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { |
|
260 |
SSLLogger.fine( |
|
261 |
"abort session resumption, " + |
|
262 |
"missing Extended Master Secret extension"); |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
} |
|
267 |
} |
|
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
268 |
} |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
269 |
|
56542 | 270 |
/** |
271 |
* Network data producer of a "extended_master_secret" extension in |
|
272 |
* the ServerHello handshake message. |
|
273 |
*/ |
|
274 |
private static final |
|
275 |
class SHExtendedMasterSecretProducer implements HandshakeProducer { |
|
276 |
// Prevent instantiation of this class. |
|
277 |
private SHExtendedMasterSecretProducer() { |
|
278 |
// blank |
|
279 |
} |
|
280 |
||
281 |
@Override |
|
282 |
public byte[] produce(ConnectionContext context, |
|
283 |
HandshakeMessage message) throws IOException { |
|
284 |
// The producing happens in server side only. |
|
285 |
ServerHandshakeContext shc = (ServerHandshakeContext)context; |
|
286 |
||
287 |
if (shc.handshakeSession.useExtendedMasterSecret) { |
|
288 |
byte[] extData = new byte[0]; |
|
289 |
shc.handshakeExtensions.put(SH_EXTENDED_MASTER_SECRET, |
|
290 |
ExtendedMasterSecretSpec.NOMINAL); |
|
291 |
||
292 |
return extData; |
|
293 |
} |
|
294 |
||
295 |
return null; |
|
296 |
} |
|
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
297 |
} |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
298 |
|
56542 | 299 |
/** |
300 |
* Network data consumer of a "extended_master_secret" extension in |
|
301 |
* the ServerHello handshake message. |
|
302 |
*/ |
|
303 |
private static final |
|
304 |
class SHExtendedMasterSecretConsumer implements ExtensionConsumer { |
|
305 |
// Prevent instantiation of this class. |
|
306 |
private SHExtendedMasterSecretConsumer() { |
|
307 |
// blank |
|
308 |
} |
|
309 |
||
310 |
@Override |
|
311 |
public void consume(ConnectionContext context, |
|
312 |
HandshakeMessage message, ByteBuffer buffer) throws IOException { |
|
313 |
// The producing happens in client side only. |
|
314 |
ClientHandshakeContext chc = (ClientHandshakeContext)context; |
|
315 |
||
316 |
// In response to the client extended_master_secret extension |
|
317 |
// request, which is mandatory for ClientHello message. |
|
318 |
ExtendedMasterSecretSpec requstedSpec = (ExtendedMasterSecretSpec) |
|
319 |
chc.handshakeExtensions.get(CH_EXTENDED_MASTER_SECRET); |
|
320 |
if (requstedSpec == null) { |
|
321 |
chc.conContext.fatal(Alert.UNSUPPORTED_EXTENSION, |
|
322 |
"Server sent the extended_master_secret " + |
|
323 |
"extension improperly"); |
|
324 |
} |
|
325 |
||
326 |
// Parse the extension. |
|
327 |
ExtendedMasterSecretSpec spec; |
|
328 |
try { |
|
329 |
spec = new ExtendedMasterSecretSpec(buffer); |
|
330 |
} catch (IOException ioe) { |
|
331 |
chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE, ioe); |
|
332 |
return; // fatal() always throws, make the compiler happy. |
|
333 |
} |
|
334 |
||
335 |
if (chc.isResumption && chc.resumingSession != null && |
|
336 |
!chc.resumingSession.useExtendedMasterSecret) { |
|
337 |
chc.conContext.fatal(Alert.UNSUPPORTED_EXTENSION, |
|
338 |
"Server sent an unexpected extended_master_secret " + |
|
339 |
"extension on session resumption"); |
|
340 |
} |
|
341 |
||
342 |
// Update the context. |
|
343 |
chc.handshakeExtensions.put( |
|
344 |
SH_EXTENDED_MASTER_SECRET, ExtendedMasterSecretSpec.NOMINAL); |
|
345 |
||
346 |
// No impact on session resumption. |
|
347 |
} |
|
348 |
} |
|
349 |
||
350 |
/** |
|
351 |
* The absence processing if a "extended_master_secret" extension is |
|
352 |
* not present in the ServerHello handshake message. |
|
353 |
*/ |
|
354 |
private static final |
|
355 |
class SHExtendedMasterSecretAbsence implements HandshakeAbsence { |
|
356 |
@Override |
|
357 |
public void absent(ConnectionContext context, |
|
358 |
HandshakeMessage message) throws IOException { |
|
359 |
// The producing happens in client side only. |
|
360 |
ClientHandshakeContext chc = (ClientHandshakeContext)context; |
|
361 |
||
56559
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
362 |
if (SSLConfiguration.useExtendedMasterSecret && |
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
363 |
!SSLConfiguration.allowLegacyMasterSecret) { |
56542 | 364 |
// For full handshake, if a client receives a ServerHello |
365 |
// without the extension, it SHOULD abort the handshake if |
|
366 |
// it does not wish to interoperate with legacy servers. |
|
367 |
chc.conContext.fatal(Alert.HANDSHAKE_FAILURE, |
|
368 |
"Extended Master Secret extension is required"); |
|
369 |
} |
|
370 |
||
371 |
if (chc.isResumption && chc.resumingSession != null) { |
|
372 |
if (chc.resumingSession.useExtendedMasterSecret) { |
|
373 |
// For abbreviated handshake, if the original session used |
|
374 |
// the "extended_master_secret" extension but the new |
|
375 |
// ServerHello does not contain the extension, the client |
|
376 |
// MUST abort the handshake. |
|
377 |
chc.conContext.fatal(Alert.HANDSHAKE_FAILURE, |
|
378 |
"Missing Extended Master Secret extension " + |
|
379 |
"on session resumption"); |
|
380 |
} else if (SSLConfiguration.useExtendedMasterSecret && |
|
56559
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
381 |
!SSLConfiguration.allowLegacyResumption && |
a423173d0578
rollbak behavior changes of extended secret extension
xuelei
parents:
56557
diff
changeset
|
382 |
chc.negotiatedProtocol.useTLS10PlusSpec()) { |
56542 | 383 |
// Unlikely, abbreviated handshake should be discarded. |
384 |
chc.conContext.fatal(Alert.HANDSHAKE_FAILURE, |
|
385 |
"Extended Master Secret extension is required"); |
|
386 |
} |
|
387 |
} |
|
388 |
} |
|
48225
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
389 |
} |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
390 |
} |
718669e6b375
8148421: Transport Layer Security (TLS) Session Hash and Extended Master Secret Extension
xuelei
parents:
diff
changeset
|
391 |