< prev index next >

test/jdk/javax/net/ssl/TLSCommon/SSLEngineTestCase.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -83,10 +83,16 @@
          */
         ENABLED_NON_KRB_NOT_ANON_CIPHERS(
                 SSLEngineTestCase.ENABLED_NON_KRB_NOT_ANON_CIPHERS,
                 "Enabled by default non kerberos not anonymous"),
         /**
+         * Ciphers supported by TLS 1.3 only.
+         */
+        TLS13_CIPHERS(
+                SSLEngineTestCase.TLS13_CIPHERS,
+                "Supported by TLS 1.3 only"),
+        /**
          * Ciphers unsupported by the tested SSLEngine.
          */
         UNSUPPORTED_CIPHERS(SSLEngineTestCase.UNSUPPORTED_CIPHERS,
                 "Unsupported");
 

@@ -172,21 +178,26 @@
     private static final int DELAY = 1000;
     private static final String HOST = "localhost";
     private static final String SERVER_NAME = "service.localhost";
     private static final String SNI_PATTERN = ".*";
 
+    private static final String[] TLS13_CIPHERS = {
+            "TLS_AES_256_GCM_SHA384",
+            "TLS_AES_128_GCM_SHA256"
+    };
+
     private static final String[] SUPPORTED_NON_KRB_CIPHERS;
 
     static {
         try {
             String[] allSupportedCiphers = getContext()
                     .createSSLEngine().getSupportedCipherSuites();
             List<String> supportedCiphersList = new LinkedList<>();
             for (String cipher : allSupportedCiphers) {
                 if (!cipher.contains("KRB5")
+                        && !isTLS13Cipher(cipher)
                     && !cipher.contains("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) {
-
                     supportedCiphersList.add(cipher);
                 }
             }
             SUPPORTED_NON_KRB_CIPHERS =
                     supportedCiphersList.toArray(new String[0]);

@@ -202,10 +213,11 @@
             String[] allSupportedCiphers = getContext()
                     .createSSLEngine().getSupportedCipherSuites();
             List<String> supportedCiphersList = new LinkedList<>();
             for (String cipher : allSupportedCiphers) {
                 if (!cipher.contains("KRB5")
+                        && !isTLS13Cipher(cipher)
                         && !cipher.contains("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")
                         && !cipher.endsWith("_SHA256")
                         && !cipher.endsWith("_SHA384")) {
                     supportedCiphersList.add(cipher);
                 }

@@ -224,10 +236,11 @@
             String[] allSupportedCiphers = getContext()
                     .createSSLEngine().getSupportedCipherSuites();
             List<String> supportedCiphersList = new LinkedList<>();
             for (String cipher : allSupportedCiphers) {
                 if (cipher.contains("KRB5")
+                        && !isTLS13Cipher(cipher)
                     && !cipher.contains("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) {
                     supportedCiphersList.add(cipher);
                 }
             }
             SUPPORTED_KRB_CIPHERS = supportedCiphersList.toArray(new String[0]);

@@ -244,10 +257,11 @@
             temporary.setUseClientMode(true);
             String[] enabledCiphers = temporary.getEnabledCipherSuites();
             List<String> enabledCiphersList = new LinkedList<>();
             for (String cipher : enabledCiphers) {
                 if (!cipher.contains("anon") && !cipher.contains("KRB5")
+                        && !isTLS13Cipher(cipher)
                     && !cipher.contains("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) {
                     enabledCiphersList.add(cipher);
                 }
             }
             ENABLED_NON_KRB_NOT_ANON_CIPHERS =

@@ -301,10 +315,20 @@
      */
     public SSLEngineTestCase() {
         this.maxPacketSize = 0;
     }
 
+    private static boolean isTLS13Cipher(String cipher) {
+        for (String cipherSuite : TLS13_CIPHERS) {
+            if (cipherSuite.equals(cipher)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     /**
      * Wraps data with the specified engine.
      *
      * @param engine        - SSLEngine that wraps data.
      * @param wrapper       - Set wrapper id, e.g. "server" of "client".

@@ -711,12 +735,17 @@
                     case "DTLSv1.0":
                     case "TLSv1":
                     case "TLSv1.1":
                         runTests(Ciphers.SUPPORTED_NON_KRB_NON_SHA_CIPHERS);
                         break;
-                    default:
+                    case "DTLSv1.1":
+                    case "TLSv1.2":
                         runTests(Ciphers.SUPPORTED_NON_KRB_CIPHERS);
+                        break;
+                    case "TLSv1.3":
+                        runTests(Ciphers.TLS13_CIPHERS);
+                        break;
                 }
                 break;
             case "krb":
                 runTests(Ciphers.SUPPORTED_KRB_CIPHERS);
                 break;
< prev index next >