supported_versions for TLS 1.2 JDK-8145252-TLS13-branch
authorxuelei
Fri, 15 Jun 2018 14:07:25 -0700
branchJDK-8145252-TLS13-branch
changeset 56769 125890684a60
parent 56761 001e4e7c0a01
child 56782 b472b5917a1b
supported_versions for TLS 1.2
src/java.base/share/classes/sun/security/ssl/Record.java
src/java.base/share/classes/sun/security/ssl/SSLExtension.java
test/jdk/javax/net/ssl/DTLS/InvalidRecords.java
--- a/src/java.base/share/classes/sun/security/ssl/Record.java	Thu Jun 14 11:59:22 2018 -0700
+++ b/src/java.base/share/classes/sun/security/ssl/Record.java	Fri Jun 15 14:07:25 2018 -0700
@@ -190,7 +190,7 @@
             ByteBuffer m, int len) throws SSLException {
         if (len > m.remaining()) {
             throw new SSLException("Insufficient space in the buffer, " +
-                    "may be cause by unexpected end of handshake data.");
+                    "may be cause by an unexpected end of handshake data.");
         }
     }
 }
--- a/src/java.base/share/classes/sun/security/ssl/SSLExtension.java	Thu Jun 14 11:59:22 2018 -0700
+++ b/src/java.base/share/classes/sun/security/ssl/SSLExtension.java	Fri Jun 15 14:07:25 2018 -0700
@@ -319,7 +319,7 @@
 
     CH_SUPPORTED_VERSIONS   (0x002B, "supported_versions",
                                 SSLHandshake.CLIENT_HELLO,
-                                ProtocolVersion.PROTOCOLS_OF_13,
+                                ProtocolVersion.PROTOCOLS_TO_13,
                                 SupportedVersionsExtension.chNetworkProducer,
                                 SupportedVersionsExtension.chOnLoadConsumer,
                                 null,
--- a/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java	Thu Jun 14 11:59:22 2018 -0700
+++ b/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java	Fri Jun 15 14:07:25 2018 -0700
@@ -55,7 +55,7 @@
 
     @Override
     DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) {
-        if (needInvalidRecords && (ba.length >= 60) &&
+        if ((ba.length >= 60) &&
                 (ba[0x00] == (byte)0x16) && (ba[0x0D] == (byte)0x01) &&
                 (ba[0x3B] == (byte)0x00) && (ba[0x3C] > 0)) {
 
@@ -64,6 +64,16 @@
             // ba[0x3B]: length of session ID
             // ba[0x3C]: length of cookie
 
+            if (!needInvalidRecords) {
+                // The 2nd ClientHello with cookie.  The 1st one should be
+                // rejected as expected.
+                //
+                // This may happen if the last few bytes of the packet are
+                // for supported_version extension.
+                throw new RuntimeException(
+                    "the crashed handshake message was rejected as expected");
+            }
+
             // ClientHello with cookie
             needInvalidRecords = false;
             System.out.println("invalidate ClientHello message");