|
1 /* |
|
2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 /* |
|
25 * @test |
|
26 * @bug 8171279 |
|
27 * @library /javax/net/ssl/templates |
|
28 * @summary Test TLS connection with each individual supported group |
|
29 * @run main/othervm SupportedGroups x25519 |
|
30 * @run main/othervm SupportedGroups x448 |
|
31 * @run main/othervm SupportedGroups secp256r1 |
|
32 * @run main/othervm SupportedGroups secp384r1 |
|
33 * @run main/othervm SupportedGroups secp521r1 |
|
34 * @run main/othervm SupportedGroups ffdhe2048 |
|
35 * @run main/othervm SupportedGroups ffdhe3072 |
|
36 * @run main/othervm SupportedGroups ffdhe4096 |
|
37 * @run main/othervm SupportedGroups ffdhe6144 |
|
38 * @run main/othervm SupportedGroups ffdhe8192 |
|
39 */ |
|
40 import java.util.Arrays; |
|
41 import javax.net.ssl.SSLSocket; |
|
42 import javax.net.ssl.SSLServerSocket; |
|
43 |
|
44 public class SupportedGroups extends SSLSocketTemplate { |
|
45 |
|
46 private static volatile int index; |
|
47 private static final String[][][] protocols = { |
|
48 {{"TLSv1.3"}, {"TLSv1.3"}}, |
|
49 {{"TLSv1.3", "TLSv1.2"}, {"TLSv1.2"}}, |
|
50 {{"TLSv1.2"}, {"TLSv1.3", "TLSv1.2"}}, |
|
51 {{"TLSv1.2"}, {"TLSv1.2"}} |
|
52 }; |
|
53 |
|
54 // Servers are configured before clients, increment test case after. |
|
55 @Override |
|
56 protected void configureClientSocket(SSLSocket socket) { |
|
57 String[] ps = protocols[index][0]; |
|
58 |
|
59 System.out.print("Setting client protocol(s): "); |
|
60 Arrays.stream(ps).forEachOrdered(System.out::print); |
|
61 System.out.println(); |
|
62 |
|
63 socket.setEnabledProtocols(ps); |
|
64 } |
|
65 |
|
66 @Override |
|
67 protected void configureServerSocket(SSLServerSocket serverSocket) { |
|
68 String[] ps = protocols[index][1]; |
|
69 |
|
70 System.out.print("Setting server protocol(s): "); |
|
71 Arrays.stream(ps).forEachOrdered(System.out::print); |
|
72 System.out.println(); |
|
73 |
|
74 serverSocket.setEnabledProtocols(ps); |
|
75 } |
|
76 |
|
77 /* |
|
78 * Run the test case. |
|
79 */ |
|
80 public static void main(String[] args) throws Exception { |
|
81 System.setProperty("jdk.tls.namedGroups", args[0]); |
|
82 |
|
83 for (index = 0; index < protocols.length; index++) { |
|
84 (new SupportedGroups()).run(); |
|
85 } |
|
86 } |
|
87 } |